package com.example.aboutspringboot.mapper;


import com.example.aboutspringboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    //查询所有信息
    @Select("select id,name,sex,birthday,address from user")
    List<User> findAll();

    //添加信息
    @Insert("insert into user(name,sex,birthday,address)values(#{name},#{sex},#{birthday},#{address})")
    @Options(useGeneratedKeys = true,keyProperty = "id") //插入以后自动获取id
    Integer add(User user); //返回值表示更新数量

    //根据id以及传进来的User，更新信息
    @Update("update user set name=#{name},sex=#{sex},birthday=#{birthday},address=#{address} where id=#{id}")
    Integer update(User user);

    //根据id删除信息
    @Delete("delete from user where id=#{id}")
    Integer delById(int id);
}